home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0005_FILESTMP.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  46 lines

  1. { Example For GetFTime, PackTime,
  2.   SetFTime, and UnpackTime }
  3.  
  4. Uses Dos;
  5. Var
  6.   f: Text;
  7.   h, m, s, hund : Word; { For GetTime}
  8.   ftime : LongInt; { For Get/SetFTime}
  9.   dt : DateTime; { For Pack/UnpackTime}
  10. Function LeadingZero(w : Word) : String;
  11. Var
  12.   s : String;
  13. begin
  14.   Str(w:0,s);
  15.   if Length(s) = 1 then
  16.     s := '0' + s;
  17.   LeadingZero := s;
  18. end;
  19. begin
  20.   Assign(f, 'RECURSEP.PAS');
  21.   GetTime(h,m,s,hund);
  22.   ReWrite(f); { Create new File }
  23.   GetFTime(f,ftime); { Get creation time }
  24.   WriteLn('File created at ',LeadingZero(h),
  25.           ':',LeadingZero(m),':',
  26.           LeadingZero(s));
  27.   UnpackTime(ftime,dt);
  28.   With dt do
  29.     begin
  30.       WriteLn('File timestamp is ',
  31.               LeadingZero(hour),':',
  32.               LeadingZero(min),':',
  33.               LeadingZero(sec));
  34.       hour := 0;
  35.       min := 1;
  36.       sec := 0;
  37.       PackTime(dt,ftime);
  38.       WriteLn('Setting File timestamp ',
  39.               'to one minute after midnight');
  40.       Reset(f); { Reopen File For reading }
  41.       { (otherwise, close will update time) }
  42.       SetFTime(f,ftime);
  43.     end;
  44.   Close(f);   { Close File }
  45. end.
  46.